gtkwindow: Clean up the code for an optimization
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 15 Jul 2014 18:42:36 +0000 (14:42 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Tue, 15 Jul 2014 18:49:16 +0000 (14:49 -0400)
It's hard to figure out what the "expected_reply" means except under
close examination -- it's actually talking about whether this was a
reply to a ConfigureRequest or not. The inversion in the check doesn't
help either.

Make the code cleaner by moving it above the freeze/thaw case, and
making the check more explicit and without a confusing variable. If we
haven't sent any ConfigureRequests out, then it must be a gratuitous
ConfigureNotify.

gtk/gtkwindow.c

index 76608d355cf00a22b12f60c14cdfcb965c73f09c..c3ae869b4eb5661eb79fac0261f3993f82031c9f 100644 (file)
@@ -7131,13 +7131,28 @@ gtk_window_configure_event (GtkWidget         *widget,
   GtkAllocation allocation;
   GtkWindow *window = GTK_WINDOW (widget);
   GtkWindowPrivate *priv = window->priv;
-  gboolean expected_reply = priv->configure_request_count > 0;
 
   check_scale_changed (window);
 
   if (!gtk_widget_is_toplevel (widget))
     return FALSE;
 
+  /* If this is a gratuitous ConfigureNotify that's already
+   * the same as our allocation, then we can fizzle it out.
+   * This is the case for dragging windows around.
+   *
+   * We can't do this for a ConfigureRequest, since it might
+   * have been a queued resize from child widgets, and so we
+   * need to reallocate our children in case *they* changed.
+   */
+  gtk_widget_get_allocation (widget, &allocation);
+  if (priv->configure_request_count == 0 &&
+      (allocation.width == event->width &&
+       allocation.height == event->height))
+    {
+      return TRUE;
+    }
+
   /* priv->configure_request_count incremented for each
    * configure request, and decremented to a min of 0 for
    * each configure notify.
@@ -7156,22 +7171,6 @@ gtk_window_configure_event (GtkWidget         *widget,
       gdk_window_thaw_toplevel_updates_libgtk_only (gtk_widget_get_window (widget));
     }
 
-  /* If this is a gratuitous ConfigureNotify that's already
-   * the same as our allocation, then we can fizzle it out.
-   * This is the case for dragging windows around.
-   *
-   * We can't do this for a ConfigureRequest, since it might
-   * have been a queued resize from child widgets, and so we
-   * need to reallocate our children in case *they* changed.
-   */
-  gtk_widget_get_allocation (widget, &allocation);
-  if (!expected_reply &&
-      (allocation.width == event->width &&
-       allocation.height == event->height))
-    {
-      return TRUE;
-    }
-
   /*
    * If we do need to resize, we do that by:
    *   - setting configure_notify_received to TRUE